<script>
<!--
var sort_by = '';
var sort_order = 0;
var current_view = '';
var page = 1;

function listReload(page)
{
    $('#indexAjax').html('<div align="center"><div class="loader_admin"></div></div>');
    $('#indexAjax').load('<?php echo url_for('@document_list?document_category_id='.$document_category_id) ?>&'+$('#filterSearch').serialize(), {
        sort_by:      sort_by,
        sort_order:   sort_order,
        page:         page,
        view:         current_view,
    });
}
$(document).ready(function()
{
	<?php 
		if (isset($notify) && $notify != "")
		{
			if ($notify == "editSuccess")
			{
				$type = "success";
				$title = "Thông báo";
				$text = "Bạn đã chỉnh sửa tài liệu thành công.";
				$icon = "picon icon16 brocco-icon-info white";
			}
			?>
			$.pnotify({
				type: '<?=$type?>',
			    title: '<?=$title?>',
	    		text: '<?=$text?>',
			    icon: '<?=$icon?>',
			    opacity: 0.9,
			    history: false,
			    sticker: false
			});
			<?
		}
	?>
});
-->
</script>
<div class="row-fluid">
    <div class="span12">
        <div class="box gradient">
            <div class="title">
                <h4>
                    <span>Thư viện hình</span>
                </h4>
            </div>
            <div class="content" id="SearchForm">
  				<form class="form-horizontal" id="form-document-validate"  action="<?php echo url_for('@document_list?document_category_id='.$document_category_id) ?>" method="post" enctype="multipart/form-data">
                	<div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $document_form['name']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $document_form['name']->render(array("id" => "document_name"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $document_form['document_category_id']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $document_form['document_category_id']->render(array("class" => "nostyle", "style" => "width:100%", "id" => "document_category_id"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $document_form['file']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $document_form['file']->render(array("id" => "file"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php if(isset($document) && $document->file != null): ?> 
                    <div class="form-row row-fluid">
                    	<div class="span8">
                        	<div class="span3"><label class="form-label span3">File uploaded</label></div>
                            <div class="span8 controls">			
                                <?php echo $document->file;?>
                            </div>
                    	</div>
                    </div>
                    <?php endif ?>
					<div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $document_form['description']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $document_form['description']->render(array("id" => "document_description", "class" => "document_description")); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $document_form['content']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $document_form['content']->render(array("id" => "textarea", "class" => "tinymce")); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $document_form['is_active']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<div class="left marginR10">
                                		<?php echo $document_form['is_active']->render(array("class" => "ibutton"));  ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
			      	<?php echo $document_form['_csrf_token'];  ?>
                    <div class="form-row row-fluid">                              
                        <div class="span12">
                            <div class="row-fluid">
                                <div class="form-actions">
                                <div class="span3"></div>
                                <div class="span9 controls">
                                    <button type="submit" class="btn marginR10" name="create" value="Create">Lưu</button>
                                    <button class="btn btn-danger">Làm lại</button>
                                </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php if (isset($create_success) || isset($is_create_action)) : ?>
                    <div class="form-row row-fluid">
                        <div class="span12">
                            <div class="row-fluid">
                            	<?php if (isset($create_success) && $create_success): ?>
                                    <div class="alert alert-success">Tài liệu đã tạo thành công</div>
                                    <script>
                                        window.location.href = document.location.href;
                                    </script>
                                <?php elseif (isset($is_create_action)) :?>
                                    <div class="alert alert-error">Tài liệu không đúng</div>
                                    <script>
                                        alert("Tài liệu tạo không đúng, phải có tên");
                                        window.location.href = document.location.href;
                                    </script>
                                <?php endif ?>
							</div>
						</div>
					</div>
                    <?php endif ?>
				</form>
			</div>
		</div>
	</div>
</div>
      
<div style='padding-top:10px;'>
<div class="UITable">
  <div id="indexAjax" class='filter_form'>
    <?php include 'documentListAjax.php' ?>
  </div>
</div>
</div>